<?php

abstract class View {
    protected $js;
    protected $css;
    protected $module;
    protected $view;
    
    public abstract function createView($action, $params);
    
    public function __construct($module) {
        $this->js = array();
        $this->css = array();
        $this->view = '';
        $this->module = $module;
        if($module != false) { //MAIN PAGE IS FALSE!!!
            $dir = opendir(ROOT . '/modules/' . $module->getDir());
            while($file = readdir($dir)) {
                //if($file != '.' && $file != '..' && $file != $module->getDir() . '_Model' && $file != $module->getDir() . '_View' && $file != $module->getDir() . '_Controller') {
                    $file_a = explode('.',$file);
                    if(end($file_a) == 'js') {
                        $this->js[] = $file;
                    }
                    if(end($file_a) == 'css') {
                        $this->css[] = $file;
                    }
                //}
            }
        }
    }
    
    public function getJs() {
        return $this->js;
    }

    public function getCss() {
        return $this->css;
    }

    public function getModule() {
        return $this->module;
    }

    public function getView() {
        return $this->view;
    }    
    
    public static function hiddenInputs($params) {
        $hidden = '';
        foreach($params as $key => $value) {
            $hidden .= '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
        }
        return $hidden;
    }
    
    public static function createLink($params) {
        $getLink = 'index.php';
        foreach($params as $key => $value) {
            if($getLink == 'index.php') {
                $getLink .= '?';
            } else {
                $getLink .= '&';
            }
            $getLink .= $key . '=' .$value;
        }
        return $getLink;
    }
    
}

?>
